#!/usr/bin/python -t
import commands
import sys
import string
import re

# RETURN CODE
# 0 = OK
# 1 = WARNING
# 2 = CRITICAL
# 3 = UNKNOWN

def statuscode(checkval):
        if re.match(r'^.* OK',checkval,re.IGNORECASE):
                return 0
        elif re.match(r'^.* WARNING',checkval,re.IGNORECASE):
                return 1
        elif re.match(r'^.* CRITICAL',checkval,re.IGNORECASE):
                return 2
        else:
                return 3

if len(sys.argv)<2:
	print "ERRORE PARAMETRI"
	sys.exit(3)  #UNKNOWN


CHECK_PROCESS=str(sys.argv[1])
HOSTDB=sys.argv[1]
USERDB=sys.argv[2]
PASSDB=sys.argv[3]

strcom='mysqladmin -h '+HOSTDB+' -u '+USERDB+' -p'+PASSDB+' status'
status,comdc=commands.getstatusoutput(strcom)
if  status == 0:
	print " OK: "+comdc
	sys.exit(0)
else:
	print " CRITICAL: "+comdc
	sys.exit(2)


